home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13931 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.NetVision.net.il!news
  2. From: zivshosh@netvision.net.il ( Ziv)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to use assert( )
  5. Date: Wed, 10 Apr 1996 16:44:48 GMT
  6. Organization: NetVision LTD.
  7. Message-ID: <316be48b.3354928@news.netvision.net.il>
  8. References: <4kc3k7$dur@orion.cybercom.net>
  9. NNTP-Posting-Host: ts005p16.pop4a.netvision.net.il
  10. X-Newsreader: Forte Agent .99c/16.141
  11.  
  12. On Mon, 08 Apr 1996 21:22:15 GMT, nield@cybercom.net (John Nield)
  13. wrote:
  14.  
  15. >I am interested in the use of the assert() library function (macro?).
  16. >Neither the FAQ, nor K&R seems to have anything about it. Could
  17. >someone help me with a breif explanation of its uses and mabye some
  18. >example code? 
  19. >
  20. >I'm just starting my first project big enough to split among many
  21. >people, and from the vague explanations I've heard, assert is supposed
  22. >to be a usefull way to cause errors when someone passes your code bad
  23. >values. How do I do this?
  24. >
  25. >thanx,
  26. >
  27. >;john nield
  28. >
  29. Suppose you read a number x which should be between xmin and xmax
  30. after the reading you could write (assuming <assert.h> is #included)
  31. assert( x >= xmin && x <= xmax);
  32. if x is not in the interval the program will exit issuing a message to
  33. the screen (in DOS at least)
  34. OK?
  35. Ziv
  36.